package com.example.demo.repository;

import com.example.demo.entity.User;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import java.util.List;

public interface UserRepository extends JpaRepository<User,Integer> {
    @Query(value = "select ifnull((select max(id) from user),0)",nativeQuery = true)
    public int getMaxId();
    @Query(value="select * from user where username = ?1 limit 1",nativeQuery = true)
    public User findUserByName (@Param("name") String name);
}
